/************************************************************************************
<GoSlowDetection>  Copyright (C) <2021>  <Tao Kiang>
    This program comes with ABSOLUTELY NO WARRANTY;
    This is free software, and you are welcome to redistribute it
    under certain conditions;

    You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.

    The GNU General Public License does not permit incorporating your program
into proprietary programs.  If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library.  If this is what you want to do, use the GNU Lesser General
Public License instead of this License.  But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
************************************************************************************/
#ifndef MYHOOK_H
#define MYHOOK_H

#include <windows.h>
#include <winuser.h>
#include <QObject>
#include <QPoint>


class MyHook:public QObject
{
    Q_OBJECT
public:
    enum Model          //钩子类型类型枚举，可组合使用，如 eKey|eMouse
    {
        eNull = 0,
        eKey = 1,
        eMouse = 2,
        eMouseKey = eKey | eMouse
    }mModel;

    HHOOK keyHook ,mouseHook;     //钩子对象指针
    ~MyHook();
    static MyHook* instance();          //获取单例类指针
    void relase();
    void installHook(Model model);      //安装钩子，model参数为钩子组合类型
    void unInstallHook(Model model);    //卸载钩子

signals:
    void keyPress(unsigned int key);        //发送全局按键信号
    void mousePress(bool rl,QPoint pos);    //发送全局鼠标信号，参数rl：右键为1，左键为0，pos为按下的全局（桌面）坐标

private:
    MyHook();       //单例模式私有化构造函数，不让外面实例化。
};

#endif // MYHOOK_H
